home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000075_icon-group-sender _Thu Mar 6 11:24:38 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
4KB
Received: by cheltenham.cs.arizona.edu; Sun, 9 Mar 1997 06:28:54 MST
To: icon-group@cs.arizona.edu
Date: Thu, 06 Mar 1997 11:24:38 -0700
From: Alan Watson <alan@oldp.nmsu.edu>
Message-Id: <331F0BE6.819@oldp.nmsu.edu>
Organization: New Mexico State University
Sender: icon-group-request@cs.arizona.edu
Subject: More General Events In Icon
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 3429
I'm new to Icon. I came to it as something to add to the two tools I
have for solving problems: C on one hand and contortions with awk,
sed, m4, and other shell tools on the other. Until recently I was
singularly impressed and very optimistic, but I've come across what
appears to be a fundamental problem and it's making me think again.
I'd be very grateful if someone more experienced with Icon than I
could comment on this.
--------
A number of applications require responses to events. These events are
commonly: a mouse or keyboard action in a window (graphics events);
the passage of a certain amount of time (alarm events); and the
presense of data ready to be read from a file (input events).
Icon provides a general means to respond to graphics events in
isolation (using Event(), Pending(), and Active()) and limited means
to respond to alarm events in isolation (wait for a single alarm with
delay() and WDelay()), and very limited means to respond to input
events (poll stdin with kbhit() or wait for input from a single file
with read() or reads()). However, it provides no means to respond to
combinations of these events.
--------
Do combinations occur in practice? I think they do:
(a) As my very first exercise in learning Icon's graphics facilities,
I wrote a clock. My first attempt was:
link graphics
procedure main()
WOpen("lines=1","columns=5") | stop("can't open window");
repeat {
GotoRC(1,1);
WWrites(&clock[1:6]);
WFlush();
delay(10*1000);
}
end
The problem with this is that the window is not implicitly refreshed
as required (e.g., when it is exposed by the window manager).
Replacing the WFlush() and delay() with WDelay() does not help.
Instead, the program need to call Event():
link graphics
procedure main()
WOpen("lines=1","columns=5") | stop("can't open window");
repeat {
GotoRC(1,1);
WWrites(&clock[1:6]);
Event();
}
end
The window is now implicitly refreshed as required. Unfortunately, the
clock only tells the right time once each day. To get this to work
properly, I need to combine graphics events with alarm events.
(b) An application I use on a regular basis for image processing
combines a command line interface with a graphics browser. The requires
responding to both graphics events and input events. (Re-writing xterm
within the application would not be acceptable!)
(c) A guy down the corridor is implementing the user interface to a
telescope control system. The telescope is controlled by a networked
PC. The user interface runs on a (remote) UNIX work station. The user
interface and the PC communicate by writing and reading NFS files. The
user interface also has a command line interface and a graphical
display. The program must respond to all three kinds of events: it
handles graphical and input events as expected, but in addition must
check for a NFS file every half second or so.
--------
Throwing everything into a language is probably not a good idea.
Therefore, we should not expect one language to be able to do
everything. However, the unsuitability of Icon to these three
applications astonished me; they seemed at first glance well within
the domain of problems it is intended to solve.
Am I missing something?
Alan